package com.plian.system.controller.cqzc.plan;

import com.plian.Tools.base.BaseController;
import com.plian.Tools.pagedata.PageData;
import com.plian.system.annotation.LogOperation;
import com.plian.system.model.ListResult;
import com.plian.system.model.ObjResult;
import com.plian.system.service.cqzc.bondsapply.BondsApplyService;
import com.plian.system.service.cqzc.plan.BondsPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.*;

/**
 * 说明：发债计划
 * 创建时间:2025-01-24
 */
@RestController
@RequestMapping(value = "api/bonds_plan")
public class BondsPlanController extends BaseController {

    @Autowired
    private BondsPlanService bondsPlanService;

    @Resource
    private BondsApplyService bondsApplyService;


    /**
     * 保存
     *
     * @param
     * @throws Exception
     */
    @PostMapping(value = "/save")
	@LogOperation("发债计划-保存")
    public ObjResult save(@RequestBody PageData pd) throws Exception {
        return bondsPlanService.save(pd);
    }

    /**
     * 修改
     *
     * @param
     * @throws Exception
     */
    @PostMapping(value = "/edit")
	@LogOperation("发债计划-编辑")
    public ObjResult edit(@RequestBody PageData pd) throws Exception {
        return bondsPlanService.edit(pd);
    }

    /**
     * 根据id查询
     *
     * @param pd
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/findbyid")
    public ObjResult findbyid(@RequestBody PageData pd) throws Exception {
        return bondsPlanService.findbyid(pd);
    }

    /**
     * 根据集合删除数据
     *
     * @param pd
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/del_ids")
	@LogOperation("发债计划-删除")
    public ObjResult delids(@RequestBody PageData pd) throws Exception {
        return bondsPlanService.del_ids((List<String>) pd.get("ids"));
    }

    /**
     * 查询列表
     *
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/list")
    public ListResult listpage(@RequestBody PageData pd) throws Exception {
        return bondsPlanService.listPage(pd);
    }

    @PostMapping(value = "/reportList")
    public ListResult reportList(@RequestBody PageData pd) throws Exception {
        return bondsPlanService.reportList(pd);
    }

    /**
     * 查询未使用现有批文的发债计划
     *
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/unusedList")
    public ListResult unusedList(@RequestBody PageData pd) throws Exception {
        pd.put("unused", "1");
        return bondsPlanService.listPage(pd);
    }


    /**
     * 查询单据编号列表
     *
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/codeList")
    public ListResult codeList(@RequestBody PageData pd) throws Exception {
        pd.put("unusedApply", "1");
        return bondsPlanService.listPage(pd);
    }

//	/**
//	 * 有效期内的申请单
//	 * @param pd
//	 * @return
//	 * @throws Exception
//	 */
//	@PostMapping(value = "/periodOfValidityList")
//	public ListResult periodOfValidityList(@RequestBody PageData pd)throws Exception {
//		return bondsPlanService.periodOfValidityList(pd);
//	}

//	/**
//	 * 出资企业债券发行情况报告表
//	 * @param pd
//	 * @return
//	 * @throws Exception
//	 */
//	@PostMapping(value = "/report")
//	public ListResult report(@RequestBody PageData pd) throws Exception {
//		return bondsPlanService.report(pd);
//	}
//	/**
//	 * 出资企业债券发行情况报告表导出
//	 * @param pd
//	 * @return
//	 * @throws Exception
//	 */
//	@RequestMapping(value = "/reportExcel")
//	public void reportExcel(@RequestBody PageData pd, HttpServletResponse response, OutputStream os) throws Exception {
//		bondsPlanService.reportExcel(pd, response, os);
//	}
}